<% if false # the license inside this if block assertains to this file -%>
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
<% end -%>
<% inside_indent = (test_matrix.level + 2) * 2 -%>
<%
  config_path = if name
                  %w[absent not_exist success title_and_name]
                else
                  %w[absent not_exist success title_eq_name]
                end

  # Build out a graph of objects.
  # This graph, including the current object, will be stored in a
  # TestObjects instance.
  collector = Dependencies::DependencyGraph.new(@data_gen)
  collector.add(object, 0, (name ? :name : :title), {ensure: 'absent'})


  # Generate the Puppet manifest using the graph of objects above.
  # This manifest will be ordered by dependencies.
  resources = manifester.generate_all_objects(collector, object.name,
                                              name ? :name : :title,
                                              ensure: 'absent')

  # Creates the expect_network_* statements required for this test.
  # This includes the expect statements for all referenced resources.
  expectations = prop_data.delete_before_data(tests, object,
                                              {
                                                path: config_path + %w[before],
                                                exists: false,
                                                has_name: name
                                              }, collector)


  resource_block = resources.flatten(1).uniq.map { |r| lines(r) }.join("\n")
  res_name = "#{object.out_name.capitalize}[title0]"
-%>
          before(:each) do
<%= lines(indent(expectations, inside_indent)) -%>
          end

          subject do
            apply_with_error_check(
              <<-MANIFEST
<%= lines(indent(resource_block, inside_indent + 2)) -%>
              MANIFEST
            ).catalog.resource('<%= res_name -%>')
              .provider.ensure
          end

          it { is_expected.to eq :absent }
